import random
import time
import turtle as t
import threading
from playsound import playsound


def play_sound(sound_file):
    playsound(sound_file)


t.speed(0)
t.pensize(2)
t.hideturtle()
# for i in range(6):
#     print(f"*****{i + 1}*****")
#     for j in range(1, 6):
#         print(j)
#         r = random.randint(0, 255)
#         g = random.randint(0, 255)
#         b = random.randint(0, 255)
#         color = f"#{r:02x}{g:02x}{b:02x}"
#         t.color(color)
#         t.forward(100)
#         t.left(72)  # 360/5
#     t.left(60)  # 360/6
# t.done()

sound_file = 'Notify.wav'

for i in range(6):
    r = random.randint(0, 255)
    g = random.randint(0, 255)
    b = random.randint(0, 255)
    color = f"#{r:02x}{g:02x}{b:02x}"
    t.color(color)
    print(f"开始第{i + 1}个图形，当前坐标{t.pos()}")
    for j in range(1, 6):
        if j == 1:
            t.pensize(5)
        else:
            t.pensize(2)
        t.forward(100)
        # playsound('test.wav')
        time.sleep(0.1)
        t.left(72)  # 360/5
    t.left(60)  # 360/6
    print(f"完成第{i + 1}个图形,当前坐标{t.pos()}")
    # playsound('Notify.wav')
    thread = threading.Thread(target=play_sound, args=(sound_file,))
    thread.start()
    time.sleep(0.5)
t.done()
